package com.bawei.mall.product.controller;

import com.bawei.common.core.domain.PageResult;
import com.bawei.common.core.domain.R;
import com.bawei.common.core.domain.Result;
import com.bawei.mall.product.domain.MallProductFootmarkInfo;
import com.bawei.mall.product.service.IMallProductFootmarkInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：韩丹阳
 * @Package：com.bawei.mall.product.controller
 * @Project：mall_cloud
 * @name：MallProductFootmarkInfoController
 * @Date：2024/7/2 下午 05:28
 */
@RestController
@RequestMapping("/footmark")
public class MallProductFootmarkInfoController {

    @Autowired
    private IMallProductFootmarkInfoService mallProductFootmarkInfoService;

    /**
     * 创建浏览记录
     */
    @PostMapping("/create")
    public R create(@RequestBody MallProductFootmarkInfo mallProductFootmarkInfo) {
        mallProductFootmarkInfoService.create(mallProductFootmarkInfo);
        return R.ok();
    }


    /**
     * 查询足迹列表
     */
    @GetMapping("/list")
    public R<PageInfo<MallProductFootmarkInfo>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                     @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MallProductFootmarkInfo> mallProductFootmarkInfoList = mallProductFootmarkInfoService.list(pageNum,pageSize);
        PageInfo<MallProductFootmarkInfo> mallProductFootmarkInfoPageInfo = new PageInfo<>(mallProductFootmarkInfoList);
        return R.ok(mallProductFootmarkInfoPageInfo);
    }


    /**
     * 清空足迹
     */
    @PostMapping("/clear")
    public R clear() {
        mallProductFootmarkInfoService.clear();
        return R.ok();
    }


}
